//
// Decompiled by Jadx - 378ms
//
package me.plusne.ViewTools.View;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import de.aa;

public class RoundedRectView extends View {
    public Paint a;
    public Paint b;
    public RectF c;
    public float[] d;
    public String e;
    public int f;
    public int g;
    public int h;
    public final Rect i;

    public RoundedRectView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.e = "Hello";
        this.f = -16777216;
        this.g = -16777216;
        this.h = 4;
        this.i = new Rect();
        this.c = new RectF();
        this.d = new float[8];
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, aa.al);
            this.e = obtainStyledAttributes.getString(6);
            this.f = obtainStyledAttributes.getColor(0, this.f);
            this.g = obtainStyledAttributes.getColor(7, this.g);
            this.h = obtainStyledAttributes.getDimensionPixelSize(1, this.h);
            float dimension = obtainStyledAttributes.getDimension(4, 0.0f);
            float dimension2 = obtainStyledAttributes.getDimension(5, 0.0f);
            float dimension3 = obtainStyledAttributes.getDimension(3, 0.0f);
            float dimension4 = obtainStyledAttributes.getDimension(2, 0.0f);
            this.d = new float[]{dimension, dimension, dimension2, dimension2, dimension3, dimension3, dimension4, dimension4};
            obtainStyledAttributes.recycle();
        }
        Paint paint = new Paint(1);
        this.a = paint;
        paint.setStyle(Paint.Style.STROKE);
        this.a.setStrokeWidth(this.h);
        this.a.setColor(this.f);
        Paint paint2 = new Paint(1);
        this.b = paint2;
        paint2.setColor(this.g);
        this.b.setTextSize(26.0f);
        this.b.setTextAlign(Paint.Align.CENTER);
    }

    @Override
    public final void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        RectF rectF = this.c;
        int i = this.h;
        rectF.set(i / 2.0f, i / 2.0f, getWidth() - (this.h / 2.0f), getHeight() - (this.h / 2.0f));
        RectF rectF2 = this.c;
        float[] fArr = this.d;
        canvas.drawRoundRect(rectF2, fArr[0], fArr[1], this.a);
        Paint.FontMetrics fontMetrics = this.b.getFontMetrics();
        canvas.drawText(this.e, getWidth() / 2.0f, (getHeight() / 2.0f) - ((fontMetrics.ascent + fontMetrics.descent) / 2.0f), this.b);
    }

    @Override
    public final void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        Paint paint = this.b;
        String str = this.e;
        int length = str.length();
        Rect rect = this.i;
        paint.getTextBounds(str, 0, length, rect);
        int width = rect.width();
        int height = rect.height();
        setMeasuredDimension(View.resolveSize(Math.max((this.h * 2) + width + 24, getSuggestedMinimumWidth()), i), View.resolveSize(Math.max((this.h * 2) + height, getSuggestedMinimumHeight()), i2));
    }

    public void setBorderColor(int i) {
        this.f = i;
        this.a.setColor(i);
        this.g = i;
        this.b.setColor(i);
        invalidate();
    }

    public void setText(String str) {
        this.e = str;
        invalidate();
        requestLayout();
    }

    public void setTextColor(int i) {
        this.g = i;
        this.b.setColor(i);
        invalidate();
    }
}
